package appconfig

import (
	"fmt"
	"github.com/spf13/viper"
)

type Mysql struct {
	Host     string
	Port     int
	User     string
	Password string
	Database string
}
type Redis struct {
	Host     string
	Port     int
	Password string
	Database int
}
type QiNiuYun struct {
	AccessKey string
	SecretKey string
	Bucket    string
	Url       string
}

type SendSms struct {
	APIID  string
	APIKEY string
}

type AppConfig struct {
	Mysql
	Redis
	QiNiuYun
	SendSms
}

var Config AppConfig

func Init() {
	var err error

	viper.SetConfigFile("../appconfig/dev.yaml")
	err = viper.ReadInConfig()
	if err != nil {
		panic(err)
	}
	err = viper.Unmarshal(&Config)
	if err != nil {
		panic(err)
	}
	fmt.Println("读取配置文件", &Config)
}
